﻿#ifndef DATASTRUCT_H
#define DATASTRUCT_H

#include <QString>
#include <QStringList>
#include <QMap>

namespace importCfgDataStruct{

struct importCfgData{
    QString etpFilePath;
    QStringList sdyFilePath;

};

}


namespace etpXmlDataStruct{

struct EtpProp{
    QString id;
    QString name;
    QString value;
    QString configuration;
};

struct EtpProps{
    QList<EtpProp> propList;
};

struct fileProp{
    QString id;
    QString name;
    QString value;
};

struct FileProps{
    QList<fileProp> propList;
};

struct FileRef{
    QString id;
    QString persist;
    FileProps fileProps;
};

struct Elements{
    QList<FileRef> fileRefList;
};

struct Folder{
    Elements elements;
    QString id;
    QString extensions;
    QString name;
};

struct EtpRoots{
    QList<Folder> folderList;
};

struct Configuration{
    QString id;
    QString name;
};

struct Configurations{
    QList<Configuration> configList;
};

struct EtpXmlData{
    QStringList sgfxPath;
    QString etpVersion;
    EtpProps etpProps;
    EtpRoots etpRoots;
    Configurations configs;
    QStringList rdmfPath;
    QString id;
    QString oidCount;
    QString defaultConfig;
};

}


namespace sgfxXmlDataStruct {

struct ConVar{
    QString name;
    QString type;
    QString oid;
    QString instancepath;
    QString subelement;
};

struct EventVar{
    QString name;;
    QString layerId;
    QString widgetId;
    QString paramId;
};

\
struct MappingItem{
    ConVar conVar;
    EventVar eventVar;
};

struct SdyContent{
    QList<MappingItem> inputItems;
    QList<MappingItem> outputItems;
};

/*========<??>=========*/
struct XmlVersion{
    QString name;
    QString value;
};

struct DomVersion{
    QString name;
    QString value;
};

struct ScadeRelease{
    QString name;
    QString value;
};



/*========</>=========*/

struct Project{
    QString path;
};

struct Ratio{
    QString Horizontal;
    QString Vertical;
};

struct IDE{
    Project project;
    Ratio ratio;
};
//ide


struct ColorMode{
    QString value;
};

struct Dimension{
    QString height;
    QString width;
};

struct Symbology{
    ColorMode colorMode;
    Dimension demension;
};
//symbology


struct LibraryVersion{
    QString value;
};

struct SuppVersion{
    QString value;
};

struct ApplicationId{
    QString value;
};


struct A661{
    LibraryVersion libraryVersion;
    SuppVersion suppVersion;
    ApplicationId applicationId;
};
//A661


struct PathFromRoot{
    QString value;
};

struct Declaration{};

struct Visible{
    QString value;
};

struct X{
    QString value;
};

struct Y{
    QString value;
};

struct Origin{
    X x;
    Y y;
};

struct Id{
    QString value;
};

struct LayerProperties{
    QString name;
    Visible visible;
    Origin origin;
    Id id;
    Ratio ratio;
};
//layerprop




struct Width{
    QString value;
};

struct Height{
    QString value;
};


struct Scale{
    X x;
    Y y;
};

struct Rotate{
    QString value;
};

struct Orientation{
    QString value;
};


struct File{
    QString name;
};

struct Include{
    QString path;
};

struct Parameter{
    QString name;
    QString type;
    QString enumType;
    QString initValue;
    QString enumValue;
};

struct InputParameters{

    QList<Parameter> paramers;

};

struct OutputParameters{

    QList<Parameter> paramers;

};


struct ModelIDE{
    QString value;
};

struct Padding{
    QString padBytes;
    QString align;
};

struct Prop{
    QString name;
    QString type;
    QString value;
    QString enumType;
};

struct Definition{
    QList<Padding> paddings;
    QList<Prop> props;
};

struct Msg{
    QString value;
};

struct ModelRunTime{
    QList<Msg> msgs;
};

struct Model{
    ModelIDE mide;
    Definition definition;
    ModelRunTime modelRunTime;
};

struct EventMsg{
    QString msgType;
};

struct WidgetEvents{
    QList<EventMsg> EventMsgs;
};

struct Widget{
    Model model;
    WidgetEvents events;
};

struct WidgetExtension{
    Model model;
    WidgetEvents events;
};

struct Variable{
    QString name;
    QString id;
    QString type;
};

struct Event{
    QString name;
    QList<Variable> vars;
};

struct ComWidget{
    QString name;
    QList<Event> msgs;
    QList<Event> ntfs;
};

struct CommuParams{
    QList<ComWidget> widgets;
};

struct Rule{
    Widget widget;
    QString name;
    bool hasChildren;
    bool isContainer;
};

struct Rules{
    QList<Rule> rules;
};

struct ExtensionRule{
    WidgetExtension widgetExtension;
    QString name;
};

struct ExtensionRules{
    QList<ExtensionRule> extensionRules;
};

struct PropTypes{
    QList<QString> posYList;
    QList<QString> posXList;
    QList<QString> m20List;
    QList<QString> angleList;
    QList<QString> arrayList;
    QList<QString> intList;
    QList<QString> enumList;
    QList<QString> stringList;
    QMap<QString,QString> enum2initMap;
};

struct Extension{
    QString name;
    QString enable;
    QList<Parameter> eParams;
};

struct Extensions{
    QList<Extension> extensionList;
};

struct WidgetChildren;  // 前置声明 WidgetChildren


struct DllProperties {

    PathFromRoot pathFormRoot;      // 控件容器：从根路径的路径

    QString name;                   // DLL 属性：名称
    QString type;                   // DLL 属性：类型
    Visible visible;                // DLL 属性：可见性
    Origin origin;                  // DLL 属性：起点
    Width width;                    // DLL 属性：宽度
    Height height;                  // DLL 属性：高度
    Scale scale;                    // DLL 属性：缩放
    Rotate rotate;                  // DLL 属性：旋转
    Orientation orientation;        // DLL 属性：方向
    File file;                      // DLL 属性：文件
    Include include;                // DLL 属性：包含

    QString posY;
    QString posX;



    InputParameters inputParameters;   // DLL 属性：输入参数
    OutputParameters outputParameters; // DLL 属性：输出参数

    Extensions extensions;             // DLL属性：拓展参数

    //Events widgetEvents;              //DLL属性：widget事件


    WidgetChildren* groupChildren;   // DLL 属性：子组


    ~DllProperties();               // DLL 属性的析构函数
    void addchildren(WidgetChildren *wc);  // 添加子组件的方法
};

struct WidgetChildren;  // 前置声明 WidgetChildren




struct WidgetContainer {
    QString oid;                    // 控件容器：对象标识符

    DllProperties dllProperties;    // 控件容器：DLL 属性
};





struct WidgetChildren {
    //    WidgetChildren() {}             // 子组件：默认构造函数
    //    WidgetChildren(WidgetChildren*); // 子组件：带有另一子组件作为参数的构造函数
    //    QList<WidgetContainer> widgets;  // 子组件：包含的控件容器列表

    WidgetChildren()
        : parent(nullptr)  // 初始化 parent 指针为空
    {
        // 默认构造函数，widgets 自动初始化为空列表
    }

    //    WidgetChildren(const WidgetChildren & rh):
    //        parent(rh.parent),
    //        widgets(QList<WidgetContainer>()) {
    //        qDebug() << "copy constructor of WidgetChildren";
    //    }

    WidgetChildren(WidgetChildren* wc)
        : parent(wc)  // 使用传入的指针初始化 parent
    {
        if (wc) {
            // 复制控件容器列表
            this->widgets = wc->widgets;

            // 这里可以复制其他成员变量或进行其他初始化
            // 例如：this->someOtherMember = wc->someOtherMember;
        }
        else {
            // 处理 wc 为 nullptr 的情况

        }
    }

    WidgetChildren* parent;              // 父组件指针
    QList<WidgetContainer> widgets;     // 子组件包含的控件容器列表

};




struct Layer{
    QString oid;
    PathFromRoot pathFormRoot;
    // Declaration declaration;
    LayerProperties layerProperties;
    //Events layerEvents;
    WidgetChildren widgetChildren;
    QString layerId;
    QString contextNumber;
    QString width;
    QString height;
};
//layer


struct LayerChildren{
    QList<Layer> layers;
};
//layers


struct Specification{
    QString oid;
    IDE ide;
    Symbology Symbology;
    A661 a661;
    QString conRcPath;
    QString conRcTopLevel;
    LayerChildren layerChildren;
};
//specification


struct SGFX{
    XmlVersion xmlVersion;
    DomVersion domVersion;
    ScadeRelease scadeRelease;
    Specification specification;
    QString etpPath;
};
//sgfx

}

#endif // DATASTRUCT_H
